
//
//  NetWorkingTool.m
//  大洋帝国
//
//  Created by dllo on 16/3/29.
//  Copyright © 2016年 郭宝. All rights reserved.
//

#import "NetWorkingTool.h"

@implementation NetWorkingTool
+(void)netWorkingWithURL:(NSString *)strURL block:(void (^)(id))block{
    NSURL *url = [NSURL URLWithString:strURL];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        dispatch_queue_t queue = dispatch_get_main_queue();
        dispatch_async(queue, ^{
            id result = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
            block(result);
        });
    }];
    [task resume];
}
@end
